﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.Design;
using U.B.DoMain;
using U.B.ErrorCode;
using U.B.ReadApi.Command;
using U.B.ReadApi.Dto;


namespace U.B.ReadApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MenuController : ControllerBase
    {
        private readonly IMediator _mediator;

        public MenuController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 获取全部菜单带分页
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<Apipage<MenuDto>> GetMenusAll([FromQuery] MenuGetAllCommand command)
        {
            return _mediator.Send(command);
        }
        /// <summary>
        /// 菜单反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<Menu>> ReverseMenu( [FromQuery] ReverseMenuCommand command)
        {
                return _mediator.Send(command);
        }
        /// <summary>
        /// 获取菜单树
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<MenuTreeDto>>> GetMenuTree( [FromQuery] GetMenudatasource command)
        {
            return _mediator.Send(command);
        }
        /// <summary>
        /// 获取角色树1
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<RMDto>>> GetRoleMenu( [FromQuery] ReverseRoleMenuCommand command)
        {
            return _mediator.Send(command);
        }
        /// <summary>
        /// 导航
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<NavBarDTO>>> GetNavBar( [FromQuery] GetNavBarCommand command)
        {
                return _mediator.Send(command);
        }
      
    }
}
